import React, { useEffect, useRef, useState } from "react";
import { Button, Modal, Toast } from "antd-mobile";
import { checkENV, checkENV2, isValidArr, navigateTo, triggerAppShare } from "@/utils";
import { NotiComp } from "@/components/common";
import requewt from "@/utils/requewt";
import { API, MINI_P_ID, MINI_P_PATH, REDIRECT_COVER, REDIRECT_DESC, REDIRECT_TITLE, REDIRECT_URL } from "@/config";
import callFeedback from "@/components/common/modalFeedback";
import { triggerShare } from "@/components/pages/game/car/utils";
import useApp from "@/stores/useApp";
import Router, { useRouter } from "next/router";

const pageName = "game.ready";
const klassName = pageName.replace(/\./g, '-');

export default function VReadyComp({children, type, id, actions, handler}) {
  const [loading, setLoading] = useState(false);
  const updateShareVisible = useApp(state => state.updateShareVisible)
  const {push} = useRouter()
  const compHandler = {
    start: async () => {
      push('/wheel')
    },
    share: async () => {
      const env = checkENV();
      if (env === `mini`) {
        updateShareVisible(true)
      } else {
        await triggerAppShare()
      }

      await requewt(API.game.share)
    }
  }

  return (
    <div className={`cp-${klassName}`}>
      <div className="inner">
        <div className="content">
          {
            children
          }
          <div className="footer" style={{textAlign:'center'}}>
          {/*<Button className={`act-btn act-btn-bevel`} onClick={compHandler.share}>分享</Button>*/}
          {/*<Button className={`act-btn act-btn-diamond`} onClick={e => handler.visible(`rule`)}>查看规则</Button>*/}
          {/* <Button className={`act-btn act-btn-bevel act-btn-bevel-2`}
                  loading={loading}
                  onClick={()=>Router.back()}>返 回</Button> */}
          <Button className={`act-btn act-btn-bevel`}
                  loading={loading}
                  onClick={compHandler.start}>去抽奖</Button>
        </div>
        </div>

        
      </div>
    </div>
  )
}

